﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GrainManage.Server.Factory;
using GrainManage.Entities.Account;
using GrainManage.Entities;
using GrainManage.Server.Business;
using log4net;

namespace GrainManage.Server.Controllers
{
    public class AccountController : BaseController
    {
        private readonly AccountBusiness business = new AccountBusiness();

        public string Index()
        {
            //return Json(new InputSignIn { EncryptModel = Entities.Encrypt.EncryptModel.RSA, UserName = "bijinshu", Password = "123" },JsonRequestBehavior.AllowGet);
            return GetInfo(this, business);
        }

        public string Schema()
        {
            return GetSchema(this, business);
        }

        //************************************************POST************************************************

        [HttpPost]
        public ActionResult SignIn(InputSignIn input)
        {
            var result = business.SignIn(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult ResetPassword(InputResetPassword input)
        {
            var result = business.ResetPassword(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult ManageAccount(InputManageAccount input)
        {
            var result = business.ManageAccount(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult Register(InputRegister input)
        {
            var result = business.Register(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult SignOut(InputSignOut input)
        {
            var result = business.SignOut(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult GetEncryptKey(InputGetEncryptKey input)
        {
            var result = business.GetEncryptKey(input);
            return Json(result);
        }
    }
}
